<?php

/* @var $this yii\web\View */

use yii\helpers\Url;
use yii\helpers\Html;
use common\helpers\Render;
use common\models\Employment;
use common\models\EmploymentLog;
use common\models\EmploymentSalary;

$this->addCrumbs('雇佣列表', 'employment/employment-list');
$this->title = '雇佣详情';
?>

<div class="box-content gap flyer-form pane">
    <div class="form-item">
        <div class="input-title">订单号</div>
        <div class="input-block input-mid"><?= Render::value($data, 'order_number') ?></div>
    </div>
    <div class="form-item">
        <div class="item-inline">
            <div class="input-title">雇主</div>
            <div class="input-inline input-mid"><?= Render::value($data, 'employer_id').'：'.Render::value($data, 'employer.username') ?></div>
        </div>
        <div class="item-inline">
            <div class="input-title">设计师</div>
            <div class="input-inline input-mid"><?= Render::value($data, 'designer_id').'：'.Render::value($data, 'designer.username') ?></div>
        </div>
    </div>
    <div class="form-item">
        <div class="input-title">雇佣类型</div>
        <div class="input-block input-mid"><?= Render::show(Employment::$typeSelector, $data['type']) ?></div>
    </div>
    <div class="form-item">
        <div class="item-inline">
            <div class="input-title">开始时间</div>
            <div class="input-inline input-mid"><?= Render::value($data, 'begin') ? date('Y-m-d', strtotime(Render::value($data, 'begin'))) : '---' ?></div>
        </div>
        <div class="item-inline">
            <div class="input-title">到期时间</div>
            <div class="input-inline input-mid"><?= Render::value($data, 'finish') ? date('Y-m-d', strtotime(Render::value($data, 'finish'))) : '---' ?></div>
        </div>
    </div>
    <div class="form-item">
        <div class="item-inline">
            <div class="input-title">雇佣金</div>
            <div class="input-inline input-mid"><?= Render::amount(Render::value($data, 'total_amount')) ?></div>
        </div>
        <div class="item-inline">
            <div class="input-title">发薪日</div>
            <div class="input-inline input-mid"><?= Render::value($data, 'payday') ?></div>
        </div>
    </div>
    <div class="form-item">
        <div class="input-title">状态</div>
        <div class="input-block input-mid"><span class="flyer-status <?= Employment::$statusSelector[$data->status]['status'] ?> thin"><?= Employment::$statusSelector[$data->status]['title'] ?></span></div>
    </div>
    <div class="data-title mt-20px mb-10px">薪酬规划</div>
    <div class=" flyer-table">
        <table id="info-table" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th class="first"><i class="icon-time"></i> 发薪日期</th>
                <th><i class="icon-cny"></i> 薪酬</th>
                <th><i class="icon-cny"></i> 扣除</th>
                <th><i class="icon-bell-alt"></i> 状态</th>
                <th><i class="icon-time"></i> 实际发薪时间</th>
            </tr>
            </thead>
            <tbody>
            <?php
                if($data->employmentSalarys) {
                    foreach($data->employmentSalarys as $salary) { ?>
                        <tr>
                            <td class="first"><?= date('Y-m-d', strtotime($salary['paydate'])) ?></td>
                            <td><?= Render::amount($salary['hires']) ?></td>
                            <td><?= Render::amount($salary['deduct']) ?></td>
                            <td><?= Render::show(EmploymentSalary::$statusSelector, $salary['status']) ?></td>
                            <td><?= $salary['success_at'] ? date('Y-m-d', $salary['success_at']) : '---' ?></td>
                        </tr>
                    <?php }
                }
                else { ?>
                    <tr><td colspan="5"><i class="icon-ban-circle"></i> 暂未生成薪酬发放记录</td></tr>
                <?php }?>
            </tbody>
        </table>
    </div>
    <div class="data-title mt-20px mb-10px">操作日志</div>
    <div class=" flyer-table">
        <table id="info-table" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th class="first"><i class="icon-time"></i> 操作类型</th>
                <th><i class="icon-cny"></i> 操作备注</th>
                <th><i class="icon-time"></i> 操作时间</th>
            </tr>
            </thead>
            <tbody>
            <?php
                if($data->employmentLogs) {
                    foreach($data->employmentLogs as $salary) { ?>
                        <tr>
                            <td class="first"><?= Render::show(EmploymentLog::$handlerSelector, $salary['handler']) ?></td>
                            <td><?= $salary['remark'] ?></td>
                            <td><?= date('Y-m-d', $salary['created_at']) ?></td>
                        </tr>
                    <?php }
                }
                else { ?>
                    <tr><td colspan="5"><i class="icon-ban-circle"></i> 暂无操作记录！</td></tr>
                <?php }?>
            </tbody>
        </table>
    </div>
</div>